<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title>签到状态</title>
   <link rel="stylesheet" href="../assets/libs/particles/css/style.css">
	<link rel="stylesheet" href="../assets/css/base.css">
	<link rel="stylesheet" href="../assets/css/login.css" />
	<style>
body,h3{
 		width: 100%;
		height: 100%;
		/*background-image: url('/assets/img/1.png');*/
 }
#box{
    display: flex;
    display: -webkit-flex;
    height: 100vh;
    width: 100%;
    align-items:center;
    justify-content:center;
 	background-size:100% 100%;
}
	</style>
</head>
<body>
        <div id="particles-js"></div>
	<div id="wrapper">
	    <div id="box">
    <?PHP
    header("Content-Type: text/html; charset=utf-8");
    $lng = $_POST['lng'];//post获得用户名表单值
    $lat = $_POST['lat'];
    $stress = $_POST['stress'];
    echo "你的经纬度是:";
    echo $lng;
    echo ",";
    echo $lat;
    echo "<br>" ;
    $realstatus = "正常";
function getRealIp() {
	static $realip = null;
	if($realip !== null) {
		return $realip;
	}

	if(getenv('REMOTE_ADDR')) {
		$realip = getenv('REMOTE_ADDR');
	} else if(getenv('HTTP_CLIENT_IP')) {
		$realip = getenv('HTTP_CLIENT_IP');
	} else if (getenv('HTTP_X_FROWARD_FOR')) {
		$realip = getenv('HTTP_X_FROWARD_FOR');
	}

	return $realip;
}
$ip=getRealIp();
echo "你的定位地址是:";
echo $stress;
echo "<br>" ;

function test1() {
    echo "正在进行环境检测";
    return 0;
}
function sleepp() {
sleep(5);
}
if(test1())
    sleepp();
echo "<br>" ;
echo "检测成功";
include('connect.php');//链接数据库
$sql = "SELECT username FROM `user` WHERE ip='$ip'";
$result = mysql_query($sql);//执行sql
$realname = "";
while($row = mysql_fetch_array($result))
{
    $realname =  $row['username'];
}
echo "ip1真实:".$realname."<br>";
$sql1 = "SELECT username FROM `user` WHERE ip2='$ip'";
$result = mysql_query($sql1);//执行sql
while($row = mysql_fetch_array($result))
{
    $realname =  $row['username'];
}
echo "ip2真实:".$realname."<br>";
echo "<br>" ;
echo "你是:";
if(NULL != $realname)
    echo $realname."<br>";
else
    echo "陌生人"."<br>";
echo date("Y-m-d H:i:s")."<br>";
$date2 = date("Y-m-d H:i:s");
$sql = "SELECT * FROM `history` WHERE username='$realname'";
$name ="";
$dlip = "";
$location ="" ;
$date = "";
$status ="异常";
$result = mysql_query($sql);//执行sql
while($row = mysql_fetch_array($result))
{
    $name =  $row['username'];
    $dlip =  $row['dlip'];
    $location =  $row['location'];
    $date = $row['date'];
    $status = $row['status'];
}
if($name)
{
echo "上次登录记录"."<br>";
echo "姓名：".$name."<br>";
echo "时间：：".$date."<br>";
echo "地理位置：".$location."<br>";
// echo "登录ip：".$dlip."<br>";
echo "状态：".$status."<br>";
}
$date1 = "Y-m-d H:i:s";
if($realname)
{
    $sql = "INSERT into `history` (username, dlip, location,date,status) VALUES      ('$realname', '$ip', '$stress','$date2','正常')";
    // echo $sql;
    $result = mysql_query($sql);
    // echo $result;
    echo "成功";
}
if($realname)
{
    include('send.php');
    sc_send($realname."签到成功","你的签到时间:".$date2."<br>"."你的ip:".$ip."<br>"."你的定位地址是：".$stress."<br>"."签到状态:".$realstatus,"html","sys");
}
mysql_close();
?>
	       <!--
	       <form >
	      	<ul class="group_input">
					<li>
					  你的经纬度是：<input type="text" name="host" value="<?PHP $lng = $_POST['lng'];$lat = $_POST['lat']; echo $lng;echo ",";
    echo $lat; ?>" /><br />
					</li>
					<li>
					  你的定位地址是：<input type="text" name="host" value="<?PHP $ip=getRealIp(); echo $stress;?>" /><br />
					</li>
					<li>
					   你是：<input type="text" name="host" value="<?PHP  echo $realname;?>" /><br />
					</li>
					<li>
					   <input type="text" name="host" value="<?PHP  echo $date;?>" /><br />
					</li>
				</ul>
	   
	 </form>
	 -->
	    </div>
	</div>
	<script src="../assets/libs/jquery-1.12.4/jquery.min.js"></script>
	<script src="../assets/libs/particles/particles.min.js"></script>
	<script src="../assets/libs/particles/js/app.js"></script>
</div>